Automatic detection of CO2 rebreathing during BiPAP ventilation

Carbon dioxide rebreathing (CO2 rebreathing) significantly influences respiratory drive and the work of breathing during BiPAP ventilation. We analyzed CO2 movement during BiPAP ventilation to find a method of real time detection of CO2 rebreathing without the need of CO2 concentration measurement sampled from the circuit (method expensive and not routinely used). Observational study during routine care in 15 bed university hospital ICU. At 18 patients who required BiPAP ventilation, intubated or during noninvasive ventilation, during weaning period airflow, pressure and CO2 concentration signals were registered on both sides of venting port and 17 respiratory parameters were measured or calculated for each of 4747 respiratory cycles analyzed. Based on CO2 movement (expiration–inspiration sequences) 3 types of cycle were identified, type I and II do not induce rebreathing but type III does. To test differences between the 3 types ANOVA, t-tests, and canonical discriminant analysis (CDA) were used. Then a multilayer perceptron (MLP) network, a type of artificial neural network, using the above parameters (excluding CO2 concentration) was applied to automatically identify the three types of respiratory cycles. Of the 4747 respiratory cycles, 1849 were type I, 1545 type II, and 1353 type III. ANOVA and t-tests showed significant differences between the types of respiratory cycles. CDA confirmed a correct apportionment of 93.9% of the cycles; notably, of 97.9% of type III. MLP automatically classified the respiratory cycles into the three types with 98.8% accuracy. Three types of respiratory cycles could be distinguished based on CO2 movement during BiPAP ventilation. Artificial neural networks can be used to automatically detect respiratory cycle type III, the only inducing CO2 rebreathing.


Patients and ventilator settings
Records were performed on 18 patients stable and conscious who were intubated or under noninvasive ventilation using an inflatable air cushion (oronasal Tyco™ mask; Mallinckrodt DAR, Mirandola, Italy).The BiPAP ventilator (Vision ® ; Respironics Inc., Murrysville, PA, USA) was used in pressure support mode with a single limb circuit that comprised an exhalation port near the intubation tube or the mask (Whisper Swivel device; Respironics).The inspiratory positive airway pressures were chosen to deliver a tidal volume (V T ) of 8-10 ml/kg.For patients with no intrinsic positive end-expiratory pressure (PEEPi), 4 cm H 2 O expiratory positive airway pressure (EPAP) was used, which is the lowest possible with that ventilator.If PEEPi was present and detected on the ventilator screen, the EPAP was adjusted to obtain zero end-expiratory flow without exceeding 9 cmH 2 O.The fraction of inspired oxygen (FiO 2 ) was adjusted to maintain a minimal SpO 2 of 93%.

Recordings
Recordings that lasted from 15 to 30 min were obtained from each patient using the Biopac ® MP100 apparatus (Biopac Systems Inc., Santa Barbara, CA, USA).Calibrated pressure, airflow, O 2 , and CO 2 (aspirating capnograph device) were sampled 2 cm away from both sides of the exhalation port (Fig. 1).
To measure CO 2 concentration, the Biopac ® MP 100 measuring line was integrated with the CO 2 measurement module (CO2100C) and the AFT20 kit for gas analysis recommended by the manufacturer.The AFT20 delay is 2.4 s, based on 1.5 mm ID tubing at 1.8 m and assuming 100 ml/min (factory preset) module gas sampling flow rate.The internal volume of the gas sampling interface kit is about 4.0 ml (PCV sample line 3.336 ml, NAFTION ® dryer 0.386 ml, misc.tubing/junctions 0.278 ml).
The manufacturer of the measuring line recommends using a suction speed (pump capacity) ranging from 50 ml/min to 200 m/min.
In our study, the air suction rate from the ventilatory circuit was increased to 150 ml/min, which shortened the delay time to 1.6 s according to the formula: According to these calculations, for the proper phasing of the pressure, air flow and CO 2 concentration curves, the CO 2 concentration curves: on the patient's side and on the ventilator's side were shifted by 1.6 s (withdrawn in the timeline) relative to the other curves.
(60 s/min) × (4 ml) / (150 ml/min) = 1.6 s www.nature.com/scientificreports/Analyses of respiratory cycles and respiratory parameters were made breath by breath, after phasing CO 2 curves with flow and pressure, using Biopac ® Acq-Knowledge ® 3.7 software.The beginning and end of each inspiration and expiration were defined at the points where flow crossed the zero line.
Respiratory cycles were analyzed during expiration and inspiration, on patient's and ventilator side.For each analyzed respiratory cycle respiratory mechanics parameters were measured or calculated for the patient's and ventilator side.For the patient's side these were: inspiratory maximal pressure (insp maximal pressure Pat side), Positive end expiratory pressure, inspiratory time (Insp time), expiratory time (Exp time), frequency of breathing per minute, integral of surface under a pressure curve during inspiration (insp surface under pressure curve Pat side) and inspiratory (insp tidal volume Pat side) and expiratory (exp tidal volume Pat side) tidal volume as an integral under the flow curve, inspiratory (insp maximal flow Pat side) and expiratory (exp maximal flow Pat side) maximal flow.For the ventilator side: inspiratory (Insp tidal volume Vent side) and expiratory (Exp tidal volume Vent side) tidal volume, inspiratory (Inspiratory maximal flow Vent side) and expiratory (Expiratory maximal flow Vent side) maximal flow.The volume of CO 2 inhaled at each breath (Insp CO 2 volume per breath) was calculated for patient's side by integrating the CO 2 flow curve, defined as the product of inspiratory airflow and CO 2 concentration curve.
After initial visual analysis of several recordings using Acq-Knowledge 3.7 software reflecting the CO 2 movement (mainly gas flow and CO 2 concentration curves on both sides of the leak port) in the respiratory circuit in it's patient's and ventilator side we have made some statements necessary for the further analysis.

Classification of the three types of breath cycles
Ventilation, regardless of its type, is inevitably associated with CO 2 rebreathing, which we can call physiological.During spontaneous ventilation it is the CO 2 inhalation contained in the anatomical dead space, increased by the apparatus dead space during mechanical ventilation.At the leak circuit it is a level to leak port, including the patient part of the circuit (Fig. 1).
The CO 2 rebreathing during BIPAP ventilation is a phenomenon of inhaling an extra CO 2 from the ventilator part of the circuit during inspiration.
Amount of CO 2 in inspired, atmospheric air is negligible; thus, CO 2 rebreathing during inspiration should depend only on the CO 2 exhaled during the previous expiration.For the purposes of this study, a breathing cycle was considered and analyzed as expiration-inspiration sequences.Only the CO 2 from expiratory air exhaled into the ventilator side of the circuit, still present there at the end of expiration and re-inhaled during inspiration was considered.Each breathing cycle was analyzed visually for the presence of CO 2 on the ventilator side of the leak port during expiration and on the patient side during inspiration.
When assessing which class a given respiratory cycle belongs to, both methods were used, visual and classical, i.e. the assessment of the level of CO 2 taken from the breathing circuit.
The classical evaluation is based on the evaluation of the CO 2 concentration in the respiratory circuit on both sides of the Whisper-Sviwel device (Fig. 1).The reflection of CO 2 concentration are 2 curves: the first-CO 2 concentration on the patient side and the second-CO 2 concentration on the ventilator side.To assess whether the cycle belongs to particular classes, we followed the second CO 2 curve.The distinction between different types of breathing cycles is presented on Fig. 2

and relies on:
Type I-when CO 2 does not appear during exhalation on the ventilator side, the CO 2 curve on the ventilator side is flat and takes the values of 0 (green arrow, curve 5-Fig.2).
Type II-when CO 2 appears during exhalation on the ventilator side, but due to the constant flow from the ventilator towards the patient (to maintain a constant end expiratory pressure EPAP), it is completely flushed out through the exhalation port before the next inspiration.Positive values appear on the CO 2 curve, but they drop to 0 before starting the next inspiration (green arrow on curve 5, Fig. 2).In this type, the expiratory flow is two-phase, during expiration the direction of the airflow is reversed (curve 4, Fig. 2).Arrow "a" shows the moment of flow reversal (curve 4, Fig. 2).This moment is also visible on the ventilator's CO 2 curve-refraction in curve 5 (arrow "b", Fig. 2).
Type III-when CO 2 appears during exhalation on the side of the ventilator, but is not completely flushed out during exhalation.At the start of the next inspiration, exhaled CO 2 remains at the ventilator part of the circuit and is inhaled by the patient during next inspiration.The CO 2 curve at the start of the next inspiration is still positive (green arrow in curve 5, Fig. 2).Only in type III of breathing cycle CO 2 rebreathing appears.
The evaluation of the cycles included in the analysis was carried out independently by 3 authors.During the qualification of the cycles for analysis, the possibility of patient identification was disabled.The analysis eliminated the cycles with deteriorated registration quality, significant disturbances of the respiratory rhythm (e.g., patient's agitation or movements), difficult to assess due to significantly increased air leakage (episodes of increased leakage in non-invasive ventilated patients) or airway procedures (e.g.suctioning in invasively ventilated patients)."Borderline" respiratory cycles were also eliminated, that is, which cannot be indisputably classified into one of the 3 types.
In this way, in the process of qualifying the respiratory cycles for analysis, all cycles recorded in 2 patients were eliminated, so finally the respiratory cycles from 16 patients were analyzed.

Identification, analysis and automatic recognition of the three types of respiratory cycle
Each breath cycle was visually analyzed and categorized as type I, II or III.Then, 2 tests were performed to compare the three types of breath cycles.First, ANOVA compared the 17 parameters in the three types of cycles; second, if significant differences were found by ANOVA, an unpaired Student's t-test was used to compare pairs of cycle types (Matlab Software, MathWorks ® , MA, USA).Differences were considered significant for p < 0.05.www.nature.com/scientificreports/Second a canonical discriminant analysis (CDA) was performed to appreciate correct categorization of the cycles into the three respiratory cycle types.To test whether the three types of respiratory cycles could be identified automatically, we used a multilayer perceptron (MLP) network, which is a type of artificial neural network (PS IMAGO PRO 8 software based on the analytical engine IBM SPSS Statistics v. 28).
The totality of the classified breath was split randomly in 10 samples of equal size to conduct tenfold crossvalidation procedure.Then 10 MLP models were built.Each time one of 10 samples (sequentially) was treated as a test set and the remaining 9 samples were together treated as a training set.
Each breath is characterized by the 16 variables tested by ANOVA (but excluding the CO 2 concentration variable) which were predictors for the models.These variables were standardized.The target variable was the type of respiratory cycles.
The MLP models had two hidden layers with sigmoid function as the activation function.The number of neurons in these layers was chosen automatically.Because the target variable is categorical, for the output layer the softmax function was used as the activation function.From every training sample 70% of observations were used to correct weights associated with the connections between neurons in the MLP model and the remaining 30% of observations were used to define the stopping condition, what is a standard procedure for MLP model in IBM SPSS Statistics software.
Each of 10 models was tested on the corresponding test set and each time the accuracy of the model and the sensitivity as well as precision for each type of respiratory cycle were calculated.At the end they were averaged.For each type of respiratory cycle also the ROC curve was drawn and the area under the curve was calculated.
Here the pooling strategy for ROC performance for cross-validation was used 10 .

Ethics approval and consent to participate
This observational study was performed during routine patient care in an adult intensive care unit.Ethics approval was obtained from the local institutional review board.Patients provided informed written consent for their participation, and the study was performed in accordance with the ethical standards of the 1964 Declaration of Helsinki.
Trial registration: The study was not registered as it does not meet the ICTRP criteria of a clinical study: it is an observational study, only data from the respiratory system of the ventilator during routine treatment activities were recorded, without any interventions in relation to the patient and treatment.

Results
Based on the analysis of pressure, flow and CO 2 concentration curves on the patient and ventilator side, a model of CO 2 movement in the leak circuit during BIPAP ventilation was created.It is presented in Fig. 3.
Eighteen patients were studied.Thirteen of them were male.Mean age was 54 ± 19 years, the mean time of mechanical ventilation before the study was 8.2 ± 6.6 days.The table with the characteristics of individual patients has been included in the Supplementary Materials.11,821 respiratory cycles were manually and visually analyzed.Out of them 4747 were qualified to one of 3 types as the best fitting the model of each type: 1849 of them were qualified as type I (38.9%), 1545 as type II (32.5%) and 1353 as type III (28.5%).3224 (67.9%) respiratory cycles were registered at intubated patients, 1523 (32.1%) during noninvasive ventilation.
The number of respiratory cycles included in the analysis for individual patients ranged from 588 to 29 (mean 296.7 ± 288.5 SD, median 288.6).
Table 1 shows the 17 parameters that were measured or calculated for every breath cycle and compares them in the three categories.
ANOVA showed that all parameters differed significantly among the three types; in addition, pairwise comparisons also showed significant differences for all parameters for different breath types except for inspiratory CO 2 between type I and II breaths.CDA was performed using the same variables and showed that 93.9% of the breaths according to breath type were correctly categorized (Fig. 4).
Notably, CDA correctly identified 97.9% of type III breaths, which is important because type III breaths involve CO 2 rebreathing (Table 2).

Discussion
This study analyzed the characteristics of 4747 breaths recorded on patients who were ventilated with a single limb circuit with a leak port.First, we categorized the breaths into three types based on the CO 2 motion.Second, we demonstrated that simple characteristics that can be measured on pressure and flow curves differ according to the three types of CO 2 motion.Third, we showed that we could use a artificial neural network technique, multilayer perceptron (MLP) network, to recognize each type of breath.The results suggest that by analyzing and calculating parameters routinely measured by modern ventilators, it will be possible, after appropriate refinement of the analysis algorithm, to monitor the type of each breath, which allows for adjustment of the ventilator settings to minimize the risk of re-inhalation of CO 2 .With the computing capabilities of modern ventilators, it should be easily calculated in real time to warn the medical staff of the increased risk of CO 2 rebreathing.Importantly, this study considered the complexity of the actual continuous interactions between the effects of mechanical ventilation and their effects on the physiological regulation of ventilation in terms of drive, frequency, and the inspiratory/expiratory ratio and the possibility of non-intentional leaks.It is important to emphasize how Vol:.( 1234567890      www.nature.com/scientificreports/ the calculations were performed.At the beginning, we made one very important assumption.As the amount of inhaled CO 2 in ambient air is negligible, during mechanical ventilation using a sealed respirator system, CO 2 rebreathing during inspiration should depend mainly on the amount of CO 2 exhaled during the previous exhalation.Only the CO 2 from expiratory air exhaled into the ventilator side of the circuit, still present there at the end of expiration and re-inhaled during inspiration was considered as CO 2 rebreathing.Therefore, for the purposes of this study, a breathing cycle was considered and analyzed as expiration-inspiration sequences.Then, each breath type was identified "visually" according the CO 2 motions described at Fig. 2. Then we found that the main characteristics showed significant differences according to the type of breath, as confirmed by ANOVA and CDA, allowing us to correctly differentiate each type (with 97.9% accuracy for type III breaths).Finally, we used an artificial neural network method to analyze and categorize the three types of breath.
Our sample comprised patients who were intubated or who were non-invasively ventilated via a mask that covered the mouth and nose.The distribution of breath types in the intubation and noninvasive ventilation groups, respectively, were as follows: type I, 64% and 36%; type II, 66% and 34%; and type III, 74% and 26%.It was possible that the process needed to identify the breath type might differ according to intubation versus mask ventilation status; however, since the identification was close to 100% accurate using the MLP network, this does not appear to be a concern.Indeed, this method seems to be usable regardless of whether the patient is intubated or is using an oronasal mask.
The definition of CO 2 rebreathing adopted in our work and placed in the Method section requires a broader clarification-"The CO 2 rebreathing during BIPAP ventilation is a phenomenon of inhaling an extra CO 2 from the ventilator part of the circuit during inspiration".We adopted this definition because it corresponds to the specificity of mechanical ventilation in the BIPAP mode using a leak ventilatory circuit.
CO 2 rebreathing is inherent in every type of ventilation, both spontaneous and mechanical ventilation.During spontaneous breathing, CO 2 rebreathing affects the entire anatomical dead space-during each subsequent inspiration, CO 2 is inhaled again from the exhalation air contained in the upper respiratory tract at the end of exhalation.
In the case of mechanical ventilation, we must add an apparatus dead space to the anatomical dead space, which is where additional CO 2 inhaled during each subsequent inspiration comes from.
For the purposes of our work, we adopted a definition in which we specify that the analyzed rebreathing CO 2 will be additional CO 2 , in addition to that from the anatomical and apparatus dead space, which will be inhaled by the patient during inspiration.We did this for 2 reasons.
Firstly, equipment dead space is an inevitable phenomenon during mechanical ventilation.Manufacturers of medical equipment, including masks and ventilator tube systems, make efforts to minimize the size of this space, but its complete elimination is impossible for technical reasons.The size of the device dead space varies and depends on the type of equipment selected for a specific patient (including the size of the mask, the location of the exhalation port, …) but for patients ventilated with identical equipment it will be practically the same.And this assumption is correct regardless of the ventilation mode.However, only during mechanical ventilation conducted in the BIPAP mode in a valveless system using a leak port, we are dealing with additional CO 2 appearing in the ventilatory circuit in the part distal to the leak port, as we showed in our work, only in type III respiratory cycles.So this is the phenomenon we analyze in our work.Secondly, we would like to emphasize that the phenomenon of CO 2 rebreathing defined in this way during BIPAP ventilation does not depend on the size of the dead space apparatus.Equipment manufacturers try to reduce the size of the equipment's dead space by moving the leak port as much as possible towards the patient.In the newest masks, it is located on the mask itself.However, this does not change the essence of CO 2 rebreathing because, as our work shows, including the diagram describing the movement of CO 2 in the ventilatory circuit, it is caused by the passage of exhaust air from CO 2 to the ventilator part of the circuit between the leak port and the ventilator and the impossibility of its complete removal.elimination through the leak port until the next inspiration begins.Therefore, this is a phenomenon typical of BIPAP ventilation and which occurs outside the equipment dead space, and for this reason our definition of CO 2 rebreathing seems justified to us.
Another possible concern is that the type of breath could always be the same for a particular patient using specific ventilator settings, making continuous analysis not very relevant.However, we found that for each patient, the average percentage of breaths that showed significant rebreathing (FICO 2 > 0.1%) was 45% ± 31%.This clearly indicates that each patient shows both rebreathing and non-rebreathing.This is illustrated on the patients' records, some of which show the three types of breath during the same minute.In a previous study 8 , logistic regression analysis showed that rebreathing may depend both on the previous value of the end tidal level of CO 2 (OR = 3.09) and on the instantaneous respiratory rate expressed as breaths per minute (OR = 1.19).
In that study, a leak valve was mandatory with the single limb circuit, which was the classical Respironics Whisper Swivel that is located on the circuit close to the intubation tube or to the mask.Some studies have shown that if there is a noninvasive interface, a leak incorporated into the mask itself decreases rebreathing in bench studies 6,7 .Of course, this makes breathing more efficient by decreasing the dead space of the mask and thus the VD/VT ratio.Nevertheless, the mechanism and the risk of rebreathing we describe here remain the same.In other words, this means that the amount of CO 2 rebreathing only partially depends on the location of the leak port, whether on the mask itself or at some distance from it.To a greater extent, CO 2 rebreathing depends on how much CO 2 -rich air will be exhaled to the circuit limb between the leak port and the ventilator (ventilator part) during exhalation, and the ability to remove CO 2 from the system until the next inhalation, which depends on amount of CO 2 in the system and expiration time.
Some studies propose that a plateau exhalation device or a non-rebreather valve be used to limit the risk of rebreathing and show that these kinds of devices can eliminate rebreathing at the expense of an increase in work of breathing and of expiratory resistance 11 .On the other hand, in patients with COPD, rebreathing increases during exercise; this is related to the high expiratory flow, which is not totally eliminated during shortened www.nature.com/scientificreports/expiratory duration, which may increase in the respiratory frequency 12 .Notably, non-rebreather valves are not currently recommended, especially since a clinical trial showed negative results 11 .One limitation of our study was that the method we described here allows only a qualitative measure of whether there is rebreathing; it does not actually quantify rebreathing.The obtained data potentially enable the use of quantitative analysis of the amount of CO 2 rebreathing.It was not carried out because the authors believe that the purpose of the current work is to demonstrate the possibility of detecting CO 2 rebreathing, and qualitative and quantitative analysis of CO 2 rebreathing, in order to obtain reliable conclusions, will require the recruitment of a larger number of patients, selected for various diseases and their advancement, and it will be subject of further research.
The limitation of the study seems to be the manual assessment of individual respiratory cycles and assigning them to one of three types.As described in the Method section, this process, in order to minimize the risk of error, was performed independently by three authors who were also experienced clinical practitioners and researchers.It was based primarily on the analysis of recorded curves and the presence of CO 2 on the ventilator side during exhalation.Type I included cycles during which no CO 2 appeared at all on the CO 2 curve on the ventilator side during exhalation, type II included cycles during which CO 2 appeared on this curve but disappeared before the next inspiration began, and type III included cycles during which CO 2 was present on the side of the ventilator not only during exhalation, but its presence also persisted at the beginning of the next inspiration and could therefore move towards the patient as CO 2 rebreathing.This is illustrated in Fig. 3.
This "manual" way of analyzing respiratory cycles was necessary for several reasons.First of all, in our work we used a different method of analyzing respiratory cycles than the commonly used one.For the purposes of this work, we analyzed the respiratory cycle as an exhalation-inhalation sequence and not, as commonly assumed, inhalation-exhalation.This resulted from the logic of mechanical ventilation and CO 2 movements in the leak circuit during BIPAP ventilation shown in Fig. 2. The presence of CO 2 rebreathing and its magnitude in this mode of mechanical ventilation depends on the amount of CO 2 entering the ventilator circuit behind the Whisper-Sviwel device (to the ventilator side) and the ability of the leak circuit to eliminate it from this part of the system until the next inspiration begins.Therefore, the lack of studies available in the literature using the method we used made it impossible to base our analysis on other or even automated methods of classifying respiratory cycles.
At the same time, it seems that the method of classifying respiratory cycles is transparent and the risk of misclassification is low.Additionally, this was one of the reasons why, among other things, to minimize this risk, we included only "ideal" cycles in the analysis, i.e. undoubtedly belonging to one of the 3 types.
The correctness of the method used to classify cycles into three types was confirmed in statistical tests.
Another element to consider is that only the "ideal" breathing cycles of each of the 3 types are selected for analysis.It was a deliberate procedure that allowed for a more complete determination of the differences between the different types of respiratory cycles.During real, clinical and bedside registrations, apart from "ideal" cycles, there will be many cycles with disturbed morphology, resulting from increased patient activity or leaks during non-invasive ventilation.It is likely that continuous analysis of all respiratory cycles, including "non-ideal" ones, would not yield as high a sensitivity as analyzing only "ideal" cycles.However, this does not change the clinical value of our work, as it indicates the possibility of developing algorithms, using the methodology and analytical techniques described in our article, detecting CO 2 rebreathing also in non-ideal registrations.
The size of the study group may be a limitation of the work.The study included respiratory cycles obtained from the registration of only 18 patients.Additionally, according to the "Patient's characteristics" table in Supplementary Materials, this group was not homogeneous in terms of age, underlying disease or duration of mechanical ventilation.However, the authors do not consider this element to be a significant limitation, for several reasons.
The authors' main interest were respiratory cycles and their characteristics, described by several variables.The aim of the study was to demonstrate that the assessment of only the parameters recorded by modern ventilators, i.e. the pressure and flow in the ventilator's respiratory system, may be sufficient to detect the risk of CO 2 rebreathing without the need of additional CO 2 measurement in the ventilator circuit.
For this purpose, the respiratory cycles were analyzed, which are never identical during assisted ventilation, such as ventilation in the BIPAP mode.Each respiratory cycle, also in an individual patient, is different from the others because its characteristics are influenced by many variables on the patient's side, such as: the force generated by the patient's respiratory muscles, the speed of inspiration, the use of expiratory muscles, the amount of secretions in the respiratory tract, the degree of arousal.psychomotor and many other factors.If a larger number of patients were examined and a larger number of respiratory cycles were analyzed, an even greater variety of cycles would probably be obtained than in the registered group of 4747 respiratory cycles analyzed.This does not change the fact that the recorded pool of approximately 4.5 thousand cycles turned out to be completely sufficient to obtain satisfactory results confirming the assumed thesis, i.e. the possibility of detecting type 3 breathing cycles without the need to measure CO 2 in the ventilator circuit.
Explaining the mechanism of CO 2 rebreathing formation and linking it with the underlying pathology would allow for a better setting of the ventilator's initial parameters in a specific patient, and perhaps in the future a step towards automating the process of adapting ventilation parameters to the patient's own breathing.
Such an analysis would require more registrations in a greater number of patients with different ventilation pathologies.Only in this case will we have a database of the size necessary to make the appropriate comparisons.Unfortunately, the current database of 18 patients is too small.
The choice of deep learning model requires explanation.In our current work, we wanted to show that the parameters we recorded are good predictors for predicting our target variable, which is the type of respiratory cycle, and a relatively simple MLP model is already sufficient to obtain good results of this prediction.It seems to me that it is always advisable to use an analytical tool that is the least complex and hardware-demanding (in terms of processor performance) so that the algorithm that analyzes rebreathing can be easily implemented on as many ventilators as possible.
Using a better model, as suggested, would probably give better results, but in the case of AUC it would be a correction of 0.001 (after all, our AUC is 0.998-1.000),so small and with no significant impact on the final results.
Another key point to keep in mind is the potential clinical importance of the amount of rebreathing that comes from the circuit and adds to the anatomical dead space ventilation that we identified.Some studies note that this is not a cause for concern, especially in noninvasive ventilation, due to non-intentional leaks 13 .Nevertheless, the impact of even a slight increase or decrease in PaCO 2 and the impact of frequent and rapid changes in PaCO 2 remain unknown.However, a change as small as 1 mmHg in the PaCO 2 is a powerful stimulus in terms of regulating respiratory drive, and the PaCO 2 level has important hemodynamic effects that are mediated mainly by sympathetic stimulation of pulmonary tension, peripheral tension, and cerebral blood flow [14][15][16] .On the other hand, clinical studies clearly show that in either acute or chronic hypercapnic respiratory failure, the aim of ventilator assistance is to decrease the PaCO 2 level, which may be impeded if the BiPAP circuit induces rebreathing.
The choice of the type of capnometer used requires explanation.Determination of CO 2 concentrations in exhaust air can be performed using mainstream or sidestream techniques.
Both techniques have their advantages and disadvantages.The mainstream technique is more accurate and the measurement is made at the point of gas flow, so the reading of the CO 2 concentration value is immediate, in real time.The sidestream technique involves measuring the CO 2 concentration in the air aspirated from the respiratory circuit using a thin tube into a capnograph where the measurement is performed.Therefore, the CO 2 concentration reading is delayed by the time of gas flow from the ventilatory circuit to the capnograph and is a function of the internal volume of the supply tube and the flow rate of the pump aspirating air from the ventilatory circuit.In order to synchronize the CO 2 concentration curve with the curves of other parameters measured in the ventilator circuit, i.e. pressure and flow, in the sidestream technique it is necessary to take this delay into account, i.e. shift the CO 2 concentration curve (roll back on the time line) by the value of this delay.
The factors determining the use of the sidestream CO 2 concentration measurement technique in our study are primarily the specificity of the mechanical ventilation performed in the studied patients.In some of the examined patients, ventilation was performed non-invasively, i.e. using a mask attached to the face.The condition for the effectiveness of such ventilation is to maintain the tightness of the connection between the mask and the patient's face.In the sidestream technique, the test requires the addition of a small and, above all, light plastic connector with a thin tube that discharges the tested gas to the analyzer located outside the ventilator tubing.This testing technique does not change the conditions for non-invasive ventilation.
If we use the mainstream technique, the CO 2 concentration detector, much larger and heavier, should be placed directly on the ventilator tubing, between the mask and the venting port.The weight of the detector and the cable connecting to the analyzer would burden the mask and could result in loss of tightness of the ventilatorpatient system and uncontrolled leaks disturbing the recording.The problem was important because we wanted the measurements in intubated and non-invasively ventilated patients to be comparable, so we maximized efforts to minimize leaks.
Moreover, in the mainstream technique it is only possible to analyze CO 2 concentrations, while in our study we also analyzed O 2 concentrations on the patient side.In the sidestream technique, unlike the mainstream technique, it is possible to analyze many gases, so this was one of the arguments for using this technique.
Of course, taking into account the measurement principle in the sidestream technique, differences in the maximum CO 2 concentration value can also be expected due to the admixture of aspirated fresh air from the ventilator circuit.However, this phenomenon is observed primarily in the case of small tidal volumes, in recordings conducted in children.Our study was based on registrations conducted in adults with tidal volumes of several hundred ml/breath, so this phenomenon should not be significant.
An important issue is whether the values obtained by both techniques are comparable and whether different CO 2 concentration values could be obtained using the mainstream technique instead of the sidestream technique.
There are few studies comparing the accuracy and comparability of both techniques during mechanical ventilation.
One of the few works is the analysis of Balogh et al. 17 , in which he showed that the results of the side and mainstream techniques do not differ significantly and are comparable when assessing end-tidal CO 2 (PETCO 2 ), intrapulmonary shunt fraction, ventilation-perfusion mismatch and volumetric CO 2 values, i.e. those, which were assessed in our study.
Therefore, it seems that despite certain limitations of the sidestream measurement technique, the curve records obtained thanks to it and their accuracy are sufficient to confirm the theses assessed in our work.
Another problem is the impact of possible air leaks, which are inherent in non-invasive ventilation, on CO 2 rebreathing.Some of our patients were non-invasively ventilated using a face mask.
Air leak during non-invasive ventilation obviously affects the amount of CO 2 rebreathing.This leak occurs between the mask and the patient's face, is always unidirectional and in the case of BIPAP ventilation causes two phenomena: (1) Removal of CO 2 -rich air from the equipment dead space and (2) Removal of CO 2 -rich air from the part of the ventilatory circuit distal to the leak port, which changes thus turning parts of cycles that could be type III cycles without this leak into type II cycles in which CO 2 rebreathing will not occur.
From the point of view of CO 2 rebreathing air leaks could be paradoxically beneficial phenomenon, but these benefits are obviously outweighed by unfavorable side effects in the form of respirator-patient desynchronization, reduced patient comfort or excessive drying of the inspiratory air.
Air leakage during BIPAP ventilation is more severe during inspiration, when the pressure in the ventilatory circuit is higher, but may also persist during exhalation.This phenomenon also occurs in our study.As shown in Table 1, the Insp tidal volume Pat side is on average higher than the expiratory tidal volume Pat side, which is most likely due to leakage, although it was not noticeable.clinically.
However, it seems that the phenomenon of air leaks does not have a significant impact on the results obtained in our work.This is mainly due to the method of analysis of respiratory cycles we used, i.e. in the adopted sequence of analysis in the order of exhalation-inhalation.
By adopting this assumption, we analyze primarily the impact of exhalation parameters on the amount of CO 2 rebreathing appearing in the next inhalation.Air leakage, occurring mainly during inspiration, limits the volume of the inspiratory tidal volume but has a small impact on the exhalation parameters we analyze, which determine the amount of CO 2 entering the distal part of the ventilatory circuit and affect CO 2 rebreathing.
The air leak that may occur during exhalation has a lower value than during inhalation and, of course, may affect the amount of CO 2 rebreathing, but in the same way as described above, i.e. reducing its amount.
Thus, air leaks appear to reduce CO 2 rebreathing.Minimizing or even removing air leaks may improve noninvasive ventilation compliance but may intensify CO 2 rebreathing during BIPAP ventilation.

Conclusions
CO 2 movement in the leak circuit during BIPAP ventilation was described and presented in a form of a scheme.
A close relationship was observed between the way of exhalation and the emergence of CO 2 rebreathing.Based on CO 2 movement 3 types of cycle were identified, type I and II do not induce rebreathing but type III does.
Using 16 ventilatory parameters (only the flow and pressure functions) measured or calculated for each of the 4747 tested respiratory cycles and a multilayer perceptron (MLP), a type of artificial neural network, it was possible to automatically classify the respiratory cycles into the three types with very high, 98.8% accuracy.This makes it possible to automatically detect on line CO 2 rebreathing without the need to measure CO 2 in the ventilator circuit.The system could be easy to implement as it uses pressure and flow signals commonly monitored in practically all modern ventilators.
The method described can allow to elaborate the systems of continuous warning the medical staff about the risk of CO 2 rebreathing and perhaps, in future, a method of automatic modification of ventilatory parameters to reduce CO 2 rebreathing and thus improve the patient's synchronization and compliance with the ventilator.

Figure 1 .
Figure 1.Measurement line.Measuring sensors placed on both sides of the leak port (Whisper-Swivel device).Patient side-part of the ventilator circuit between the leak port and the patient, Ventilator side-part of the ventilator circuit between the leak port and the ventilator, BIPAP-ventilator BIPAP.Measurements after Patient side: Pneumotachograph I-flow measurement Flow I using a differential pressure transducer, on one arm of the transducer a measurement of the pressure in the respiratory tract is performed after Patient side, CO 2 I and O 2measurement of CO 2 and O 2 values.Measurements after Ventilator side: Pneumotachograph II-measurement of Flow II flow using a differential pressure transducer, CO 2 II-measurement of CO 2 values after Ventilator side.

Figure 2 .
Figure 2. 3 types of respiratory cycles: The curves show: 1-pressure, patient side, 2-flow, patient side, 3-patient side, CO 2 concentration, 4-flow, ventilator side, and 5-ventilator side, CO 2 concentration.Exp expiration, Insp inhalation.Vertical lines mark the beginning and end of expiration and inspiration in the breathing cycle, crossing the point of 0 flow on the patient-side flow curve (curve 2).The height of the individual curves has been manually modified for better visualization and does not correspond to their actual values.Black arrows with "a" and "b" markings on the curves for the type II breathing cycle: 4-flow, ventilator side and 5-CO 2 concentration, ventilator side, mark the moment of reversal of the flow direction during exhalation-from the initial expiratory flow from the patient in towards the flow of the ventilator, in the second phase of exhalation, towards the patient and the Whisper-Sviwel device.The reversal of the direction of expiratory flow in type II results from the decreasing values of the patient's expiratory flow, which at indicated moments becomes smaller than the constant flow towards the patient generated by the BIPAP ventilator, necessary to maintain a constant expiratory positive airway pressure EPAP.The green arrows indicate the CO 2 concentration values on curve 5 at the start of the next inspiration: for type I and type II these values are 0, while they are positive for type III.The illustrations are print screens of actual measurements performed on patients using AcqKnowledge 3.7 (Biopac System Inc., Santa Barbara, CA, USA).

Figure 3 .
Figure3.A model of CO2 movement for the three types of respiratory cycles during BiPAP ventilation.Type I-when CO 2 does not appear during exhalation on the ventilator side, all exhalation air is removed during exhalation through the leak port, CO 2 does not appear on the patient's side during exhalation, Type II-the exhalation is so intense that CO 2 -rich exhalation air appears during exhalation on the ventilator side, but due to the constant flow from the ventilator towards the patient (to maintain a constant end expiratory pressure EPAP through the BIPAP device), it is completely flushed out through the exhalation port before the next inspiration.Type III-here also CO 2 appears during exhalation on the side of the ventilator, but is not completely flushed out during exhalation.At the start of the next inspiration, exhaled CO 2 remains at the ventilator part of the circuit and is inhaled by the patient during next inspiration.

Table 2 .
Classification matrix using canonical discriminant analysis (CDA) to analyze 16 parameters.The first column shows the true number of breaths in each group (type I, II, and III).Columns 3, 4, and 5 show how CDA categorized the breaths to each group.

Table 3 .
MLP model quality obtained as a result of tenfold cross-validation procedure.

Table 4 .
Area under curve (AUC) for MLP model obtained as a result of tenfold cross-validation procedure.